<template>
  <div class="code-layout">
    <div class="code-materials">
      <br />
      <div class="file">
        <file-list :biz_id="id" :type="type" :is_public="true" v-if=" id"/>
      </div>
      <md-preview :biz_id="id" :type="type"  :is_public="true" class="preview"  v-if="id"/>
    </div>
    <div class="code-info">
      <h3 class="info-title">基本信息</h3>
      <ul class="info-item">
        <li>
          <span class="key">名称:</span>
          <span class="val">{{ detailData.name }}</span>
        </li>
        <li>
          <span class="key"> 创建人： </span>
          <span class="val">{{
            detailData.create_user && (detailData.create_user.nick_name ||
              detailData.create_user.username)
          }}</span>
        </li>
        <li>
          <span class="key">创建时间： </span>
          <span class="val">{{ detailData.create_time }}</span>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    let typeMap = { '0': 'dataset', '1': 'workspace', '2': 'model' }
    
    return {
      id: null,
      type: typeMap[this.$route.query.active]
      //  detailData: {}
    };
  },
  props: ['detailData', 'version','active'],
  async created() {
    this.getData()
  },
  async mounted() {
    this.$nextTick(() => {
      console.log(this.detailData)
    })
  },
  
  destroyed() {

  },
  methods: {
    getData(){
      console.log("active",this.active)
      console.log("version",this.version)
      if ( this.active ==0 ){
        this.id = this.detailData.id
      }
      if ( this.active ==1 ){
        this.id = this.version.id
      }
      if ( this.active ==2 ){
        this.id = this.version.id
      }
      console.log("id", this.id)
    }

  }
}
</script>
<style lang="less" scoped>
@import "~@/assets/css/code.less";
</style>